/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package mk_tools;

import java.awt.Font;
import java.awt.event.*;
import javax.swing.*;

/**
 *
 * @author Mikael Köhlmyr
 */

public class Bookmarker{
    public JFrame window;
    public JPanel panel;
    public JLabel text;
    public JLabel text2;
    public JMenuBar menubar;
    public JMenu actions;
    public JMenuItem addbook;
    public JTextField newbook;
    public JTextField newtags;
    public JButton savebutton;
    public static final int width = 280;
    public static final int height = 140;
    
    
    public Bookmarker(){
        initComponents();
    }

    private void initComponents(){
        window = new JFrame("Bookmarker");
            window.setBounds(0, 0, width, height);
            
            window.setResizable(false);
            window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        panel = new JPanel();
        text = new JLabel();
        menubar = new JMenuBar();
            actions = new JMenu();
                addbook = new JMenuItem();

        text.setText("No current action");
        addbook.setText("New bookmark (CTRL+N)");
        actions.setText("Actions");

        window.setJMenuBar(menubar);
            menubar.add(actions);
                actions.add(addbook);
        window.add(panel);
        panel.add(text);


        window.setVisible(true);


        addbook.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                clear(evt);
                drawNewbookForm();
            }
        });
    }


    private void drawNewbookForm(){
        text = new JLabel();
            text.setText("URL:");
            panel.add(text);
        newbook = new JTextField(21);
            panel.add(newbook);
        text2 = new JLabel();
            text2.setText("Seperated by ', ':");
            panel.add(text2);
        newtags = new JTextField(15);
            panel.add(newtags);
        savebutton = new JButton();
            savebutton.setText("Save");
            panel.add(savebutton);

        update();
    }


    private void clear(ActionEvent evt){
        panel.remove(text);
        update();
        My.outStr(evt.getActionCommand());
    }

    private void update(){
        panel.revalidate();
        panel.repaint();
    }

}
